import { IFeidaoAiNodejsComponent } from '@dfeidao/atom-nodejs/interfaces';
import nodejs from '@dfeidao/atom-nodejs/msg/nodejs';
import render from '@dfeidao/atom-nodejs/render/render';
import p001 from './p001';
import p002 from './p002';


export default async function na001(fd: IFeidaoAiNodejsComponent) {
	// todo
	const res =await nodejs<{d1:{}[];d2:Array<{no:string;source_type:string}>}>(fd.data.actionid,fd.data.sessionid,'order-satisfaction/zj-000001/s001');
	const ret = Array();
	for (let i = 0; i < res.d2.length; i++) {
		ret[i] = res.d2[i].source_type;
	}
	const s = Array.from(new Set(ret));
	const a = Array();
	for (let i = 0; i < s.length; i++) {
		if(s[i]=="1"){
			a[i]="总服务台";
			
		}else if(s[i]=="2"){
			a[i]="服务台";
	
		}else if(s[i]=="3"){
			a[i]="客户报障";
	
		}else{
			a[i]="内部报障";
		}
	}
	const b = Array();
	for (let index = 0; index <s.length; index++) {
		b[index] = {s:s[index],a:a[index]};
	}	
	render(fd.data.node,res.d1,p001,'p001');
	render(fd.data.node,b,p002,'p002');
	
}
